package main

import (
	"fmt"
	"math"
	"reflect"
)

func main() {

	a := 'a'
	fmt.Println(reflect.TypeOf(rune(a)))
	fmt.Println(a)

	arr := []int{4,2,5,7,1}
	fmt.Println(maopao(arr))

	fmt.Println(erfen(arr, 4))
}

func maopao(arr []int) []int {

	for i := 0; i < len(arr) -1; i++ {
		for j := i + 1; j < len(arr); j++ {
			if arr[i] < arr[j] {
				arr[i], arr[j] = arr[j], arr[i]
			}
		}
	}
	return arr
}

func erfen(arr []int, s int) int {

	h := len(arr)
	l := 0
	for l <= h {
		min := int(math.Ceil(float64((h - l) / 2)))
		if arr[min] == s {
			 return min
		} else if arr[min] > s {
			h = min - 1
		} else {
			l = min + 1
		}
	}
	return -1
}
